var change_emergency_type = [['1' , '特急-1天'] , ['3' , '急件-3天'] , ['7' , '普通-7天']];
var change_level_type = [['A' , 'A'] , ['B' , 'B'] , ['C' , 'C']];
var effective_type = [['1' , '长期'] , ['2' , '短期']];
var reason_code_type = [['1' , '客户变更'] , ['2' , '供应商变更'], ['3' , '工程变更'] , ['4' , '质量改善'], ['5' , '设计变更'] , ['6' , '资材变更'], ['7' , '降本要求'] , ['8' , '安规要求'], ['9' , '纠错'] , ['10' , '其他']];
var change_phase_type = [['1' , '样品'] , ['2' , '小批量'], ['3' , '中批量'] , ['4' , '无需验证']];
var impact_for_reliability = [['1' , '风险可控'] , ['2' , '风险不可控'], ['3' , '无影响']];
var impact_for_product_handle = [['1' , '积压报废'] , ['2' , '降价销售'], ['3' , '返工再使用、销售'], ['4' , '无影响']];
var eva_result = [['1' , '同意变更'] , ['2' , '不同意变更']];

function choseDepartmentMgr(title, fn ,parentPanel) {
	var approvedMgrId = createProxyComm2({width:300,emptyText:'请选择...',fieldLabel:'本部门科长名称'} , 
		{url:sys_base_url + 'getUsersByDept?deptId='+login_user_dept_id}
	);
	
	var form = getMyEmptyForm([approvedMgrId]);
	var win = getEmptyPanel3([{
		text:'确定' , handler:function() {
			if(!approvedMgrId.getValue()){
				showTip2('提示' , '必须选择批准科长' , 3);   
				return;
			}
			fn.call(this , approvedMgrId.getValue());
			win.close();
		}
	}] , getBt(title) , form , 110 , 550 , parentPanel);
}

function choseEvaluateDepartment(title, fn ,parentPanel) {
	var evaDept = createProxyComm2({width:300,emptyText:'请选择...',fieldLabel:'评审部门'} , 
		{url:sys_base_url + 'getDepartmentKV'}
	);
	var evaDeptMgr = createProxyComm2({width:300,emptyText:'请选择...',fieldLabel:'评审部门领导'},
		{url:sys_base_url + 'getUsersByDept'});
	// 级联
   	evaDept.on('select', function(){
		evaDeptMgr.store.load({
			params:{deptId:evaDept.getValue()}
		});
    });

	var form = getMyEmptyForm([evaDept, evaDeptMgr]);
	var win = getEmptyPanel3([{
		text:'确定' , handler:function() {
			if(!evaDeptMgr.getValue()){
				showTip2('提示' , '必须选择评审部门' , 3);   
				return;
			}
			fn.call(this , evaDept.getValue(), evaDeptMgr.getValue());
			win.close();
		}
	}] , getBt(title) , form , 140 , 550 , parentPanel);
}

function fillRejectReason(title, fn) {
	var rejectReason = getArea({width:300,height:80,name:'rejectedReason',fieldLabel:'拒绝理由'});
	
	var form = getMyEmptyForm([rejectReason]);
	var win = getEmptyPanel3([{
		text:'确定' , handler:function() {
			if(!rejectReason.getValue()){
				showTip2('提示' , '必须填拒绝理由' , 3);   
				return;
			}
			fn.call(this , rejectReason.getValue());
			win.close();
		}
	}] , getBt(title) , form , 160 , 550 , null);
}

function selectTestPlanApprover(title, fn) {
	var testPlanApprover = createProxyComm2({width:300,emptyText:'请选择...',fieldLabel:'验证计划表审批人'} , 
		{url:sys_base_url + 'getUsersByDept?deptId='+login_user_dept_id}
	);
	
	var form = getMyEmptyForm([testPlanApprover]);
	var win = getEmptyPanel3([{
		text:'确定' , handler:function() {
			if(!testPlanApprover.getValue()){
				showTip2('提示' , '必须选择审批人' , 3);   
				return;
			}
			fn.call(this , testPlanApprover.getValue());
			win.close();
		}
	}] , getBt(title) , form , 110 , 550 , null);
}

function choseQualityDepartment(title, fn ,parentPanel) {
	var qualityDept = createProxyComm2({width:300,emptyText:'请选择...',fieldLabel:'质量部门'} , 
		{url:sys_base_url + 'getDepartmentKV'}
	);
	var qualityDeptUser = createProxyComm2({width:300,emptyText:'请选择...',fieldLabel:'部门人员'},
		{url:sys_base_url + 'getUsersByDept'});
	
	// 级联
   	qualityDept.on('select', function(){
		qualityDeptUser.store.load({
			params:{deptId:qualityDept.getValue()}
		});
    });

	var form = getMyEmptyForm([qualityDept, qualityDeptUser]);
	var win = getEmptyPanel3([{
		text:'确定' , handler:function() {
			if(!qualityDept.getValue() || !qualityDeptUser.getValue()){
				showTip2('提示' , '必须选择质量科处理人' , 3);   
				return;
			}
			fn.call(this , qualityDeptUser.getValue());
			win.close();
		}
	}] , getBt(title) , form , 140 , 550 , parentPanel);
}


// 内部变更管理
function getInternalChangeManagePanel(t) {return new CMS.InternalChangeManagePanel(t)};
var INTERNAL_CHANGE_MANAGE_PANEL;
CMS.InternalChangeManagePanel = function(title) {
	INTERNAL_CHANGE_MANAGE_PANEL = this;
	var objArr = converArr([
		{name:'id' , width:50 , sortable:true , header:'变更号'},
		{name:'productName' , width:120 , sortable:true , header:'适用产品'},
		{name:'productSerialNumber' , width:120 , sortable:true , header:'适用型号'},
		{name:'project' , width:120 , sortable:true , header:'适用工程'},
		{name:'emergency',hidden:true},{name:'emergencyString' , width:120 , sortable:true , header:'变更紧急度状态'},
		{name:'changeType',hidden:true} , 
		{name:'changeTypeName',hidden:true} , 
		{name:'level',hidden:true},
		{name:'effective',hidden:true} , 
		{name:'effectiveStartDate',hidden:true} , {name:'effectiveEndDate',hidden:true} , 
		{name:'effectiveString',hidden:true},
		//{name:'effectiveString' , width:140 , sortable:true , header:'变更时效'},
		{name:'reasonCode',hidden:true},{name:'reasonString' , width:80 , sortable:true , header:'变更理由'},
		{name:'supportAccordance',hidden:true},
		{name:'reasonDesc',hidden:true},
		/*{name:'supportAccordance' , width:80 , sortable:true , header:'支撑依据'},
		{name:'reasonDesc' , width:80 , sortable:true , header:'变更原因简述'},*/
		{name:'appliedUserId',hidden:true},
		{name:'applierUserName',hidden:true},
		//{name:'applierUserName' , width:80 , sortable:true , header:'申请人'},
		{name:'appliedDeptId',hidden:true},
		{name:'appliedDeptName',hidden:true},
		//{name:'appliedDeptName' , width:80 , sortable:true , header:'申请部门'},
		{name:'status',hidden:true},{name:'statusString' , width:120 , sortable:true , header:'状态'},
		{name:'verifyRuleDocUrl',hidden:true},
		{name:'evaDeptId',hidden:true},
		{name:'approvedMgrId',hidden:true},
		{name:'approvedMgrName',hidden:true},
		{name:'approvedDate',hidden:true},
		{name:'beforeChangeStatus',hidden:true},
		{name:'afterChangeStatus',hidden:true},
		{name:'appliedAttachment',hidden:true},
		
		{name:'evaImpactForReliability',hidden:true},
		{name:'evaImpactForReliabilityString',hidden:true},
		{name:'evaImpactForProductHandle',hidden:true},
		{name:'evaImpactForProductHandleString',hidden:true},
		{name:'evaImpactForProduceEfficiency',hidden:true},
		{name:'mustVerify',hidden:true},
		{name:'mustVerifyString',hidden:true},
		{name:'mustAlertCustomer',hidden:true},
		{name:'mustAlertCustomerString',hidden:true},
		{name:'mustSpplierChange',hidden:true},
		{name:'mustSpplierChangeString',hidden:true},
		{name:'customerSupAlertBy',hidden:true},
		{name:'customerSupAlertByName',hidden:true},
		{name:'productTreatmentAdvise',hidden:true},
		{name:'result',hidden:true},
		{name:'resultString',hidden:true},
		{name:'evaComments',hidden:true},
		{name:'evaLeader',hidden:true},
		{name:'evaLeaderName',hidden:true},
		{name:'evaDeptMgrId',hidden:true},
		{name:'evaDeptMgrName',hidden:true},
		{name:'evaDeptId',hidden:true},
		{name:'evaDeptName',hidden:true},
		{name:'evaDate',hidden:true},
		{name:'resultReportUrl',hidden:true},
		
		{name:'sampleReportURL',hidden:true},
		{name:'sampleIsQualified',hidden:true},
		{name:'sampleIsQualifiedString',hidden:true},
		{name:'smallReportURL',hidden:true},
		{name:'smallIsQualified',hidden:true},
		{name:'smallIsQualifiedString',hidden:true},
		{name:'middleReportURL',hidden:true},
		{name:'middleIsQualified',hidden:true},
		{name:'middleIsQualifiedString',hidden:true},
		{name:'isFinishedAlertCustomer',hidden:true},
		{name:'isFinishedAlertCustomerString',hidden:true},
		{name:'alertCustomerNumber',hidden:true},
		{name:'isFinishedSupChange',hidden:true},
		{name:'isFinishedSupChangeString',hidden:true},
		{name:'finishedSupChangeNumber',hidden:true},
		{name:'isFinishedSecurity',hidden:true},
		{name:'isFinishedSecurityString',hidden:true},
		{name:'attachmentForAlert',hidden:true},
		{name:'other',hidden:true},
		{name:'changeResultIsQualify',hidden:true},
		{name:'changeResultIsQualifyString',hidden:true},
		{name:'isApproveChange',hidden:true},
		{name:'isApproveChangeString',hidden:true},
		{name:'rejectReason',hidden:true},
		{name:'verifyMembers',hidden:true},
		{name:'deployChangeDate',hidden:true},
		{name:'resultReportUrl',hidden:true},
		{name:'rejectedByName',hidden:true},
		{name:'rejectedDate',hidden:true},
		{name:'rejectedReason',hidden:true},
		{name:'testPlanApprover',hidden:true},
		{name:'testPlanRejectedReason',hidden:true},
		{name:'testItemsString',hidden:true},
		
		{name:'researchDeptIsBomChanged',hidden:true},
		{name:'researchDeptIsBomChangedString',hidden:true},
		{name:'researchDeptIsDrawingChnaged',hidden:true},
		{name:'researchDeptIsDrawingChnagedString',hidden:true},
		{name:'researchDeptIsDesignDocChanged',hidden:true},
		{name:'researchDeptIsDesignDocChangedString',hidden:true},
		{name:'researchDeptFinishedDate',hidden:true},
		{name:'researchDeptUserId',hidden:true},
		{name:'researchDeptUserName',hidden:true},
		{name:'researchDeptAttachment',hidden:true},
		{name:'engineeringDeptIsBomChanged',hidden:true},
		{name:'engineeringDeptIsBomChangedString',hidden:true},
		{name:'engineeringDeptIsSopChanged',hidden:true},
		{name:'engineeringDeptIsSopChangedString',hidden:true},
		{name:'engineeringDeptIsMoldChanged',hidden:true},
		{name:'engineeringDeptIsMoldChangedString',hidden:true},
		{name:'engineeringDeptIsProcChanged',hidden:true},
		{name:'engineeringDeptIsProcChangedString',hidden:true},
		{name:'engineeringDeptIsQcChanged',hidden:true},
		{name:'engineeringDeptIsQcChangedString',hidden:true},
		{name:'engineeringDeptFinishedDate',hidden:true},
		{name:'engineeringDeptUserId',hidden:true},
		{name:'engineeringDeptUserName',hidden:true},
		{name:'engineeringDeptAttachment',hidden:true},
		{name:'qualityDeptIsInspectDocChanged',hidden:true},
		{name:'qualityDeptIsInspectDocChangedString',hidden:true},
		{name:'qualityDpetIsTrained',hidden:true},
		{name:'qualityDpetIsTrainedString',hidden:true},
		{name:'qualityDpetIsUpgradeInspection',hidden:true},
		{name:'qualityDpetIsUpgradeInspectionString',hidden:true},
		{name:'qualityDeptIsMarkInFirst3',hidden:true},
		{name:'qualityDeptIsMarkInFirst3String',hidden:true},
		{name:'qualityDeptFinishedDate',hidden:true},
		{name:'qualityDeptUserId',hidden:true},
		{name:'qualityDeptUserName',hidden:true},
		{name:'qualityDeptAttachment',hidden:true},
		{name:'productDeptIsMaterialChecked',hidden:true},
		{name:'productDeptIsMaterialCheckedString',hidden:true},
		{name:'productDeptIsTrained',hidden:true},
		{name:'productDeptIsTrainedString',hidden:true},
		{name:'productDeptIsRegisted',hidden:true},
		{name:'productDeptIsRegistedString',hidden:true},
		{name:'productDeptFinishedDate',hidden:true},
		{name:'productDeptUserId',hidden:true},
		{name:'productDeptUserName',hidden:true},
		{name:'productDeptAttachment',hidden:true},
		{name:'summaryIsNumberBeforeChangeSup',hidden:true},
		{name:'summaryIsNumberBeforeChangeSupString',hidden:true},
		{name:'summaryNumberBeforeChangeSup',hidden:true},
		{name:'summaryDeliverDateAfterChange',hidden:true},
		{name:'summaryIsNumberBeforeChangeProd',hidden:true},
		{name:'summaryIsNumberBeforeChangeProdString',hidden:true},
		{name:'summaryNumberBeforeChangeProd',hidden:true},
		{name:'summaryIsImpactShipMent',hidden:true},
		{name:'summaryIsImpactShipMentString',hidden:true},
		{name:'summaryNewProdBatchNumber',hidden:true},
		{name:'summaryNewProdDeliverDate',hidden:true},
		{name:'summaryDeptUserId',hidden:true},
		{name:'summaryDeptUserName',hidden:true},
		{name:'summaryDeptAttachment',hidden:true},
		
		{name:'id',header:'操作',width:480, renderer:function(v,c,row) {
			var data = row.data;
			var status = data['status'];
			var ret=' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.viewDetail()">查看详情</a>'
				+' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.viewReportDetail()">查看通知单</a>';
			
			if(login_user_id != data['appliedUserId']){
				if(status=='1')
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.approveRequest()">批准</a>'
						+' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.rejectRequest()">拒绝</a>';
				else if(status=='2')
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.setVerifyTeam()">组织验证人员</a>';
				else if(status=='3')
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.setChangeType()">判定变更类别和阶段</a>';
				else if(status=='4'){
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.fillEvaluationResult()">变更评审</a>';
				}else if(status=='5' || status=='14'){
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.setVerifyRule(1)">设置验证规则</a>';
				}else if(status=='6' ){
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.setVerifyRule(2)">查看验证规则表</a>';
				}else if(status=='7'){
					var phase = data['level'];
					// A阶段，样本
					if(phase == 'A')
						ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.uploadResultReport(\'SAMPLE\')">样本报告</a>';
					// B阶段，小批量
					else if(phase == 'B'){
						ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.uploadResultReport(\'SAMPLE\')">样本报告</a>'
							+ ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.uploadResultReport(\'SMALL\')">小批量报告</a>';
					}
					// C阶段，中批量
					else if(phase == 'C'){
						ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.uploadResultReport(\'SAMPLE\')">样本报告</a>'
							+ ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.uploadResultReport(\'SMALL\')">小批量报告</a>'
							+ ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.uploadResultReport(\'MIDDLE\')">中批量报告</a>';
					}
					
					var sampleReportURL = data['sampleReportURL'];
					var smallReportURL = data['smallReportURL'];
					var middleReportURL = data['middleReportURL'];
					// 如果有报告记录，可以查看
					if(	sampleReportURL != "" || smallReportURL != "" || middleReportURL != ""){
						ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.viewReports()">查看报告</a>'
					}
					
					ret+= ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.finishUploadReport()">结束上传报告</a>';
				}else if(status=='8'){
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.alertSupCust()">通报客户和供应商</a>';
				}else if(status=='9'){
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.confirmEvaluation()">确认评审</a>';
				}else if(status=='22'){
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.approveDeploy(10)">同意下发</a>'
						+' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.approveDeploy(23)">拒绝下发</a>';
				}else if(status=='10'){
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.selectDeployDeptUsers()">下发变更</a>';
				}else if(status=='17'  && data['evaLeader']==login_user_id){
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.finished()">结束流程</a>';
				}
			}else{
				if(status=='1' && data['appliedUserId']==data['approvedMgrId'])
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.approveRequest()">批准</a>'
						+' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.rejectRequest()">拒绝</a>';
				else if(status=='2' && data['appliedUserId']==data['evaDeptMgrId'])
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.setVerifyTeam()">组织验证人员</a>';
				else if(status=='3' && data['appliedUserId']==data['evaLeader'])
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.setChangeType()">判定变更类别和阶段</a>';
				else if((status=='4'||status=='14') && data['appliedUserId']==data['evaLeader']){
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.fillEvaluationResult()">变更评审</a>';
				}else if(status=='5' && data['appliedUserId']==data['evaLeader'])
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.setVerifyRule(1)">设置验证规则</a>';
				else if(status=='6' && data['appliedUserId']==data['testPlanApprover']){
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.setVerifyRule(2)">查看验证规则表</a>';
				}else if(status=='7' && data['appliedUserId']==data['evaLeader']){
					var phase = data['level'];
					// A阶段，样本
					if(phase == 'A')
						ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.uploadResultReport(\'SAMPLE\')">样本报告</a>';
					// B阶段，小批量
					else if(phase == 'B'){
						ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.uploadResultReport(\'SAMPLE\')">样本报告</a>'
							+ ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.uploadResultReport(\'SMALL\')">小批量报告</a>';
					}
					// C阶段，中批量
					else if(phase == 'C'){
						ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.uploadResultReport(\'SAMPLE\')">样本报告</a>'
							+ ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.uploadResultReport(\'SMALL\')">小批量报告</a>'
							+ ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.uploadResultReport(\'MIDDLE\')">中批量报告</a>';
					}
					
					var sampleReportURL = data['sampleReportURL'];
					var smallReportURL = data['smallReportURL'];
					var middleReportURL = data['middleReportURL'];
					// 如果有报告记录，可以查看
					if(	sampleReportURL != "" || smallReportURL != "" || middleReportURL != ""){
						ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.viewReports()">查看报告</a>'
					}
					
					ret+= ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.finishUploadReport()">结束上传报告</a>';
				}else if(status=='8' && data['appliedUserId']==data['customerSupAlertBy']){
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.alertSupCust()">通报客户和供应商</a>';
				}else if(status=='9' && data['appliedUserId']==data['evaLeader']){
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.confirmEvaluation()">确认评审</a>';
				}else if(status=='22' && data['appliedUserId']==data['evaDeptMgrId']){
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.approveDeploy(10)">同意下发</a>'
						+' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.approveDeploy(23)">拒绝下发</a>';
				}else if(status=='10' && data['appliedUserId']==data['evaLeader']){
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.selectDeployDeptUsers()">下发变更</a>';
				}else if(status=='17'  && data['evaLeader']==login_user_id){
					ret += ' <a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.finished()">结束流程</a>';
				}
			}
			return ret;
		}}
	] , true);
	var productNameSearch = getField({width:190,name:'productName'});
	var ds = getPageDs(chg_base_url + 'getInternalChanges' , 'id' , objArr);
	var pageBar = getPageBBar(20 , ds);
	CMS.InternalChangeManagePanel.superclass.constructor.call(this, {
		title:title,store:ds,view:getGridView('没有找到数据'),
		columns:objArr.columns,sm:getRowModel(),bbar:pageBar,
		id:'internal_change_manager_panel',tbar:['-',{
			text:'产品名称：'
		},productNameSearch ,'-' ,{
			text:'新增',iconCls:'add',handler:function() {
				INTERNAL_CHANGE_MANAGE_PANEL.editInfo(pub_add_option);
			}
		},'-']
	});
	this.refresh = function() {
       ds.load({params:{start:0,limit:pageBar.pageSize}});
    };
    registPageDsParams(ds , [productNameSearch] , INTERNAL_CHANGE_MANAGE_PANEL.refresh);
    INTERNAL_CHANGE_MANAGE_PANEL.refresh();
    //编辑
    this.editInfo = function(type) {
    	var dWidth = 340;
    	var effectiveV = createNormlCommon(dWidth , effective_type , '变更时效' , '' , false, 'effectiveV');
    	var effectiveStartDate = creDate({fieldLabel:'开始日期',name:'effectiveStartDate',width:dWidth});
    	var effectiveEndDate = creDate({fieldLabel:'结束日期',name:'effectiveEndDate',width:dWidth});
    	var emergencyV = createNormlCommon(dWidth , change_emergency_type , '变更紧急度状态' , '' , false, 'emergencyV');
    	var reasonCodeV = createNormlCommon(dWidth , reason_code_type , '变更理由' , '' , false, 'reasonCodeV');
    	var items = [
    		getHidden({name:'id',allowNull:true}),
    		getHidden({name:'evaDeptId',allowNull:true}),
    		//createProxyComm2({width:dWidth,emptyText:'请选择...',name:'productId',fieldLabel:'适用产品'},{url:sys_basdata_url + 'getProductKV'}),
    		getField({width:dWidth,name:'productName',fieldLabel:'适用产品'}),
    		getField({width:dWidth,name:'productSerialNumber',fieldLabel:'适用型号'}),
    		getField({width:dWidth,name:'project',fieldLabel:'适用工程'}),
    		emergencyV,
    		getHidden({name:'emergency',allowNull:true}),
    		getHidden({name:'effective',allowNull:true}),
    		effectiveV,effectiveStartDate,effectiveEndDate,
    		reasonCodeV,
    		getHidden({name:'reasonCode',allowNull:true}),
    		getField({width:dWidth,name:'supportAccordance',fieldLabel:'支撑依据'}),
    		getArea({width:dWidth + 60,height:60,name:'reasonDesc',fieldLabel:'变更原因简述',allowNull:true}),
    		getArea({width:dWidth + 60,height:60,name:'beforeChangeStatus',fieldLabel:'变更前状态',allowNull:false}),
    		getArea({width:dWidth + 60,height:60,name:'afterChangeStatus',fieldLabel:'变更后状态',allowNull:false}),
    		{xtype:'textfield', fieldLabel:'附件', inputType:'file', name:'image', width:dWidth}
    	];
    	
    	effectiveV.on('select' , function() {
    		if(effectiveV.getValue() == '1'){
				effectiveStartDate.hide();
				effectiveEndDate.hide();
				effectiveStartDate.allowNull = true;
				effectiveEndDate.allowNull = true;
			}else{
				effectiveStartDate.show();
				effectiveEndDate.show();
				effectiveStartDate.allowNull = false;
				effectiveEndDate.allowNull = false;
			}
    	});
    	
    	if(type==pub_edit_option){
    		pubEditRow(type ,items , INTERNAL_CHANGE_MANAGE_PANEL , '内部变更' , 400 , 600 , chg_base_url + 'saveInternalChange', INTERNAL_CHANGE_MANAGE_PANEL.refresh);
    	}else{
    		var form1 = new Ext.form.FormPanel({
				bodyStyle:'padding:5px',
		    	deferredRender:false,
		    	defaultType: 'textfield',
		    	region:'center',
		    	items:items,
		    	fileUpload:true,
		    	labelWidth:85,
		    	autoScroll:true,
		    	id:'form1'
		    });
    		var win = getEmptyPanel3([{
	    		text:'提交' , handler:function() {
	    			var formObj = form1.getForm();
	    			if(!formObj.isValid())return;
	    			var params = checkObjs(items,{type:type})
	    			if(params) {
			    		choseDepartmentMgr('选择批准科长' , function(approvedMgrId) {		
			    			params = checkObjs(items,{type:type,approvedMgrId:approvedMgrId});	
				    		formObj.findField("emergency").setValue(emergencyV.getValue());
				    		formObj.findField("effective").setValue(effectiveV.getValue());
				    		formObj.findField("reasonCode").setValue(reasonCodeV.getValue());
				    		formObj.submit({
					   			url:chg_base_url + 'saveInternalChange',
					   			params:params,
					   			waitTitle: '请稍后',
					   			waitMsg:'提交中...',
					   			success:function(form1,resp) {
							    	uploadCallBack(resp);
							    },
							    failure:function(form1,resp){
							    	uploadCallBack(resp);
							    }
					   		});
					   		var uploadCallBack = function(resp) {
						    	var obj = resp.result;
						    	showTip2('消息' , obj.msg , 3);
						    	INTERNAL_CHANGE_MANAGE_PANEL.refresh();
						    	if(obj.status == '1') win.close();
						    }
			    		} , win);
	    			}
	    		}
	    	}] , '内部变更' , form1 , 500 , 600);
    	}
    };
    // 查看通知单
    var view_notification_win;
    this.viewReportDetail = function(){
    	view_notification_win=this;
    	var rowObj = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected();
    	var sampleReportURL = rowObj.data['sampleReportURL'];
		var smallReportURL = rowObj.data['smallReportURL'];
		var middleReportURL = rowObj.data['middleReportURL'];
		
		var status = rowObj.data['status'];
				
    	var htmlCode = SPRNSTR + '<table class=\"table\" style=\"table-layout:fixed;word-break: break-all;word-wrap:break-word;\" width=\"100%\"><tbody><tr><td class=\"plat_table-row-over\" width=\"30%\">名称</td><td class=\"plat_table-row-over\">内容</td></tr>';
    	if(	sampleReportURL != ""){
			htmlCode += '<tr><td>样品验证报告</td><td><a href='+chg_base_url+'viewDocument?docUrl='+rowObj.data['sampleReportURL']+'>样本测试报告</a></td></tr>'
    			+ '<tr><td>样品是否合格</td><td>'+rowObj.data['sampleIsQualifiedString']+'</td></tr>';
		}
    	if( smallReportURL != ""){
			htmlCode += '<tr><td>小批量验证报告</td><td><a href='+chg_base_url+'viewDocument?docUrl='+rowObj.data['smallReportURL']+'>小批量测试报告</a></td></tr>'
    			+ '<tr><td>小批量是否合格</td><td>'+rowObj.data['smallIsQualifiedString']+'</td></tr>';
		}
		if(	middleReportURL != ""){
			htmlCode += '<tr><td>中批量验证报告</td><td><a href='+chg_base_url+'viewDocument?docUrl='+rowObj.data['middleReportURL']+'>中批量测试报告</a></td></tr>'
    			+ '<tr><td>中批量是否合格</td><td>'+rowObj.data['middleIsQualifiedString']+'</td></tr>';
		}
    	htmlCode += '<tr><td>客户报备是否完成</td><td>'+rowObj.data['isFinishedAlertCustomerString']+'</td></tr>'
    		+ '<tr><td>依据</td><td>'+rowObj.data['alertCustomerNumber']+'</td></tr>'
    		+ '<tr><td>供应商变更是否完成</td><td>'+rowObj.data['isFinishedSupChangeString']+'</td></tr>'
    		+ '<tr><td>依据</td><td>'+rowObj.data['finishedSupChangeNumber']+'</td></tr>';
    	if(rowObj.data['attachmentForAlert'] != "")
    		htmlCode += '<tr><td>通报客户供应商附件</td><td><a href='+chg_base_url+'viewDocument?docUrl='+rowObj.data['attachmentForAlert']+'>附件</a></td></tr>';
    	else
    		htmlCode += '<tr><td>通报客户供应商附件</td><td>无报告</td></tr>'; 	
    	 htmlCode += '<tr><td>安全件列名是否完成</td><td>'+rowObj.data['isFinishedSecurityString']+'</td></tr>'
    		+ '<tr><td>其他</td><td>'+rowObj.data['other']+'</td></tr>'
    		+ '<tr><td>变更验证结论是否合格</td><td>'+rowObj.data['changeResultIsQualifyString']+'</td></tr>'
    		+ '<tr><td>变更前状态</td><td>'+rowObj.data['beforeChangeStatus']+'</td></tr>'
    		+ '<tr><td>变更后状态</td><td>'+rowObj.data['afterChangeStatus']+'</td></tr>'
    		+ '<tr><td>是否同意变更</td><td>'+rowObj.data['isApproveChangeString']+'</td></tr>'
    		+ '<tr><td>拒绝理由</td><td>'+rowObj.data['rejectReason']+'</td></tr>'
    		+ '<tr><td>参评人员</td><td>'+rowObj.data['verifyMembers']+'</td></tr>'
    		+ '<tr><td>变更实施时间</td><td>'+rowObj.data['deployChangeDate']+'</td></tr>'
    		+ '<tr><td>组织部门</td><td>'+rowObj.data['evaDeptName']+'</td></tr>'
    		+ '<tr><td>组织人员</td><td>'+rowObj.data['evaLeaderName']+'</td></tr>'
    		+ '<tr><td>组织部门领导</td><td>'+rowObj.data['evaDeptMgrName']+'</td></tr>';
    		
    	if(status=="17" || status=="12"){
    		htmlCode += '<tr><td>应研所-修改设计BOM并存档</td><td>'+rowObj.data['researchDeptIsBomChangedString']+'</td></tr>'
	    		+ '<tr><td>应研所-修改设计图纸并存档</td><td>'+rowObj.data['researchDeptIsDrawingChnagedString']+'</td></tr>'
	    		+ '<tr><td>应研所-修改设计规格书并存档</td><td>'+rowObj.data['researchDeptIsDesignDocChangedString']+'</td></tr>'
	    		+ '<tr><td>应研所-完成时间</td><td>'+rowObj.data['researchDeptFinishedDate']+'</td></tr>'
	    	 	+'<tr><td>应研所-处理人员</td><td>'+rowObj.data['researchDeptUserName']+'</td></tr>';
	    if(rowObj.data['researchDeptAttachment'] != "")
    		htmlCode += '<tr><td>应研所-附件</td><td><a href='+chg_base_url+'viewDocument?docUrl='+rowObj.data['researchDeptAttachment']+'>附件</a></td></tr>';
    	else
    		htmlCode += '<tr><td>应研所-附件</td><td>无报告</td></tr>';
	    		
	    htmlCode += '<tr><td>工程部门-修改工艺BOM并存档</td><td>'+rowObj.data['engineeringDeptIsBomChangedString']+'</td></tr>'
	    		+ '<tr><td>工程部门-修改SOP文档并存档</td><td>'+rowObj.data['engineeringDeptIsSopChangedString']+'</td></tr>'
	    		+ '<tr><td>工程部门-工模具准备或修改</td><td>'+rowObj.data['engineeringDeptIsMoldChangedString']+'</td></tr>'
	    		+ '<tr><td>工程部-程序准备</td><td>'+rowObj.data['engineeringDeptIsProcChangedString']+'</td></tr>'
	    		+ '<tr><td>工程部-修改QC工程图</td><td>'+rowObj.data['engineeringDeptIsQcChangedString']+'</td></tr>'
	    		+ '<tr><td>工程部-完成时间</td><td>'+rowObj.data['engineeringDeptFinishedDate']+'</td></tr>'
	    		+ '<tr><td>工程部-处理人员</td><td>'+rowObj.data['engineeringDeptUserName']+'</td></tr>';
	    if(rowObj.data['engineeringDeptAttachment'] != "")
    		htmlCode += '<tr><td>工程部-附件</td><td><a href='+chg_base_url+'viewDocument?docUrl='+rowObj.data['engineeringDeptAttachment']+'>附件</a></td></tr>';
    	else
    		htmlCode += '<tr><td>工程部-附件</td><td>无报告</td></tr>';
	    htmlCode += '<tr><td>质量部门-完成对应检验文档修改</td><td>'+rowObj.data['qualityDeptIsInspectDocChangedString']+'</td></tr>'
	    		+ '<tr><td>质量部门-完成变更培训</td><td>'+rowObj.data['qualityDpetIsTrainedString']+'</td></tr>'
	    		+ '<tr><td>质量部门-实施变更品加严检验</td><td>'+rowObj.data['qualityDpetIsUpgradeInspectionString']+'</td></tr>'
	    		+ '<tr><td>质量部门-进行前3批变更品标识</td><td>'+rowObj.data['qualityDeptIsMarkInFirst3String']+'</td></tr>'
	    		+ '<tr><td>质量部门-完成时间</td><td>'+rowObj.data['qualityDeptFinishedDate']+'</td></tr>'
	    		+ '<tr><td>质量部门-处理人员</td><td>'+rowObj.data['qualityDeptUserName']+'</td></tr>';
	    if(rowObj.data['qualityDeptAttachment'] != "")
    		htmlCode += '<tr><td>质量部门-附件</td><td><a href='+chg_base_url+'viewDocument?docUrl='+rowObj.data['qualityDeptAttachment']+'>附件</a></td></tr>';
    	else
    		htmlCode += '<tr><td>质量部门-附件</td><td>无报告</td></tr>';
	    htmlCode += '<tr><td>生产班组-生产资料齐套检查</td><td>'+rowObj.data['productDeptIsMaterialCheckedString']+'</td></tr>'
	    	 	+'<tr><td>生产班组-完成变更培训</td><td>'+rowObj.data['productDeptIsTrainedString']+'</td></tr>'
	    		+ '<tr><td>生产班组-变更执行登记</td><td>'+rowObj.data['productDeptIsRegistedString']+'</td></tr>'
	    		+ '<tr><td>生产班组-完成时间</td><td>'+rowObj.data['productDeptFinishedDate']+'</td></tr>'
	    		+ '<tr><td>生产班组-处理人员</td><td>'+rowObj.data['productDeptUserName']+'</td></tr>';
	    if(rowObj.data['productDeptAttachment'] != "")
    		htmlCode += '<tr><td>生产班组-附件</td><td><a href='+chg_base_url+'viewDocument?docUrl='+rowObj.data['productDeptAttachment']+'>附件</a></td></tr>';
    	else
    		htmlCode += '<tr><td>生产班组-附件</td><td>无报告</td></tr>';
	    htmlCode += '<tr><td>综合管理-变更前供应商物料是否有数量</td><td>'+rowObj.data['summaryIsNumberBeforeChangeSupString']+'</td></tr>'
	    		+ '<tr><td>综合管理-变更前供应商物料数量</td><td>'+rowObj.data['summaryNumberBeforeChangeSup']+'</td></tr>'
	    		+ '<tr><td>综合管理-变更后交付时间</td><td>'+rowObj.data['summaryDeliverDateAfterChange']+'</td></tr>'
	    		+ '<tr><td>综合管理-变更前产品、在制品是否有数量</td><td>'+rowObj.data['summaryIsNumberBeforeChangeProdString']+'</td></tr>'
	    		+ '<tr><td>综合管理-变更前产品、在制品数量</td><td>'+rowObj.data['summaryNumberBeforeChangeProd']+'</td></tr>'
	    		+ '<tr><td>综合管理-变更是否影响产品出货</td><td>'+rowObj.data['summaryIsImpactShipMentString']+'</td></tr>'
	    		+ '<tr><td>综合管理-新产品首批号</td><td>'+rowObj.data['summaryNewProdBatchNumber']+'</td></tr>'
	    		+ '<tr><td>综合管理-配送时间</td><td>'+rowObj.data['summaryNewProdDeliverDate']+'</td></tr>'
	    		+ '<tr><td>综合管理-处理人员</td><td>'+rowObj.data['summaryDeptUserName']+'</td></tr>';
	    if(rowObj.data['summaryDeptAttachment'] != "")
    		htmlCode += '<tr><td>综合管理-附件</td><td><a href='+chg_base_url+'viewDocument?docUrl='+rowObj.data['summaryDeptAttachment']+'>附件</a></td></tr>';
    	else
    		htmlCode += '<tr><td>综合管理-附件</td><td>无报告</td></tr>';
    	}
    		
    	htmlCode += '</tbody></table>' + EPRNSTR;
    	var btns = [{
			text:'打印申请单',handler:function() {
				printPage(htmlCode);
			}
		},{
			text:'关闭',handler:function() {
				win.close();
			}
		}];
		
		if(status=='17' || status=='18' || status=='19' || status=='20' || status=='21'){
			btns = [{
				text:'执行变更',handler:function() {
					INTERNAL_CHANGE_MANAGE_PANEL.deployChange(status);
				}
			},{
				text:'关闭',handler:function() {
					win.close();
				}
			}];
		}
		
    	var win = new Ext.Window({
			height:500 , width:600 , layout:'border',title:'变更申请单详情',buttonAlign:'center',items:[{
				border:false,closable:true,scripts:true,autoScroll:true,region:'center',
	            discardUrl:true,nocache:true,timeout:9000,scope:this,html:htmlCode
			}],buttons:btns
		});
		win.show();
		
		this.closeParentWin = function(){
			win.close();
		};
    }
    // 查看申请单详情
    this.viewDetail = function(){
    	var rowObj = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected();
    	var htmlCode = SPRNSTR + '<table class=\"table\" style=\"table-layout:fixed;word-break: break-all;word-wrap:break-word;\" width=\"100%\"><tbody><tr><td class=\"plat_table-row-over\" width=\"30%\">名称</td><td class=\"plat_table-row-over\">内容</td></tr>'
    		+ '<tr><td>适用产品</td><td>'+rowObj.data['productName']+'</td></tr>'
    		+ '<tr><td>适用型号</td><td>'+rowObj.data['productSerialNumber']+'</td></tr>'
    		+ '<tr><td>适用工程</td><td>'+rowObj.data['project']+'</td></tr>'
    		+ '<tr><td>变更紧急度状态</td><td>'+rowObj.data['emergencyString']+'</td></tr>';
    	if(rowObj.data['status']>3 && rowObj.data['status']!=13){
    		htmlCode += '<tr><td>变更类别</td><td>'+rowObj.data['changeTypeName']+'</td></tr>'
    				+'<tr><td>变更等级</td><td>'+rowObj.data['level']+'</td></tr>';
    	}
    	htmlCode += '<tr><td>变更时效</td><td>'+rowObj.data['effectiveString']+'</td></tr>'
    		+ '<tr><td>变更理由</td><td>'+rowObj.data['reasonString']+'</td></tr>'
    		+ '<tr><td>支撑依据</td><td>'+rowObj.data['supportAccordance']+'</td></tr>'
    		+ '<tr><td>变更原因简述</td><td>'+rowObj.data['reasonDesc']+'</td></tr>'
    		+ '<tr><td>变更前状态</td><td>'+rowObj.data['beforeChangeStatus']+'</td></tr>'
    		+ '<tr><td>变更后状态</td><td>'+rowObj.data['afterChangeStatus']+'</td></tr>'
    		+ '<tr><td>申请部门</td><td>'+rowObj.data['appliedDeptName']+'</td></tr>'
    		+ '<tr><td>申请人员</td><td>'+rowObj.data['applierUserName']+'</td></tr>';
    		
    	if(rowObj.data['appliedAttachment'] != "")
    		htmlCode += '<tr><td>附件</td><td><a href='+chg_base_url+'viewDocument?docUrl='+rowObj.data['appliedAttachment']+'>附件</a></td></tr>';
    	else
    		htmlCode += '<tr><td>附件</td><td>无报告</td></tr>';
    	
    	
    	if(rowObj.data['status']>1 && rowObj.data['status']!=13){
    		htmlCode += '<tr><td>批准领导</td><td>'+rowObj.data['approvedMgrName']+'</td></tr>'
    		+ '<tr><td>批准时间</td><td>'+rowObj.data['approvedDate']+'</td></tr>';
    	}
    	htmlCode += '<tr><td>状态</td><td>'+rowObj.data['statusString']+'</td></tr>';
    		
    	if(rowObj.data['status']==13 || rowObj.data['status']==15 || rowObj.data['status']==16){
    		htmlCode += '<tr><td>拒绝人</td><td>'+rowObj.data['rejectedByName']+'</td></tr>'
    			+ '<tr><td>拒绝理由</td><td><font color=red>'+rowObj.data['rejectedReason']+'</font></td></tr>'
    			+ '<tr><td>拒绝时间</td><td>'+rowObj.data['rejectedDate']+'</td></tr>';
    	}
    	if(rowObj.data['status']==14){
    		htmlCode += '<tr><td>变更实验计划拒绝理由</td><td>'+rowObj.data['testPlanRejectedReason']+'</td></tr>';
    	}
    	
    	// 包含评审内容
    	if(rowObj.data['status']>6){
    		htmlCode += '<tr><td>产品安全、可靠性影响</td><td>'+rowObj.data['evaImpactForReliabilityString']+'</td></tr>'
    			+'<tr><td>在产品、原物料处理风险</td><td>'+rowObj.data['evaImpactForProductHandleString']+'</td></tr>'
    			+'<tr><td>生产效率的影响</td><td>'+rowObj.data['evaImpactForProduceEfficiency']+'</td></tr>'
    			+'<tr><td>是否需要验证</td><td>'+rowObj.data['mustVerifyString']+'</td></tr>'
    			+'<tr><td>是否需要通报客户</td><td>'+rowObj.data['mustAlertCustomerString']+'</td></tr>'
    			+'<tr><td>是否需要供应商变更</td><td>'+rowObj.data['mustSpplierChangeString']+'</td></tr>'
    			+'<tr><td>成品及原物料处理意见</td><td>'+rowObj.data['productTreatmentAdvise']+'</td></tr>'
    			+'<tr><td>评审结论</td><td>'+rowObj.data['resultString']+'</td></tr>'
    			+'<tr><td>评审备注</td><td>'+rowObj.data['evaComments']+'</td></tr>'
    			+'<tr><td>评审组长</td><td>'+rowObj.data['evaLeaderName']+'</td></tr>'
    			+'<tr><td>评审部门领导</td><td>'+rowObj.data['evaDeptMgrName']+'</td></tr>'
    			+'<tr><td>评审部门</td><td>'+rowObj.data['evaDeptName']+'</td></tr>'
    			+'<tr><td>评审时间</td><td>'+rowObj.data['evaDate']+'</td></tr>'
    			+'<tr><td>实验项目</td><td>'+rowObj.data['testItemsString']+'</td></tr>';
    	}
    		
    	htmlCode += '</tbody></table>' + EPRNSTR;
    	var btns = [{
			text:'打印申请单',handler:function() {
				printPage(htmlCode);
			}
		},{
			text:'关闭',handler:function() {
				win.close();
			}
		}];
		
    	var win = new Ext.Window({
			height:500 , width:600 , layout:'border',title:'变更申请单详情',buttonAlign:'center',items:[{
				border:false,closable:true,scripts:true,autoScroll:true,region:'center',
	            discardUrl:true,nocache:true,timeout:9000,scope:this,html:htmlCode
			}],buttons:btns
		});
		win.show();
    }
    
    // 删除
    this.deleteRow = function() {
    	pubDeleteRow(INTERNAL_CHANGE_MANAGE_PANEL , 'id' , '内部变更' , chg_base_url + 'saveInternalChange' , ds , INTERNAL_CHANGE_MANAGE_PANEL.refresh);
    };
    
    // 部门经理拒绝变更单
    this.rejectRequest = function(){
    	var id = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['id'];
    	var appliedUserId = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['appliedUserId'];
    	fillRejectReason('拒绝理由' , function(rejectReason) {		
			ajax({
				url:chg_base_url + 'rejectInternalChange',
				params:{id:id,rejectedReason:rejectReason,appliedUserId:appliedUserId},
			    waitMsg:'提交中...',
				success:function(resp) {
					var respText = Ext.util.JSON.decode(resp.responseText);
	    			showTip2('提示' , respText['msg'] , 2);
	    			INTERNAL_CHANGE_MANAGE_PANEL.refresh();
				}
			});
		});
    };
    // 部门经理批准变更单
    this.approveRequest = function(){
    	var id = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['id'];
    	
    	choseEvaluateDepartment('选择评审部门和领导' , function(evaDept,evaDeptMgr) {		
			ajax({
				url:chg_base_url + 'approveInternalChange',
			   	params:{id:id,evaDeptId:evaDept,evaDeptMgrId:evaDeptMgr},
			   	waitTitle: '请稍后',
			   	waitMsg:'提交中...',
			   	success:function(resp) {
			   		var respText = Ext.util.JSON.decode(resp.responseText);
	    			showTip2('提示' , respText['msg'] , 2);
	    			INTERNAL_CHANGE_MANAGE_PANEL.refresh();
				}
			});
		});
    	
    };
    
    // 设置验证人员组
    this.setVerifyTeam = function(){
    	var dWidth = 340;
    	var id = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['id'];
    	var evaDeptId = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['evaDeptId'];
    	var items = [
    		createProxyComm2({width:dWidth,emptyText:'请选择...',name:'evaLeader',fieldLabel:'评审组长',allowBlank:false},{url:sys_base_url + 'getUsersByDept?deptId='+evaDeptId})
    	];
    	var form = getMyEmptyForm(items);
   		var win = getEmptyPanel3([{
    		text:'提交' , handler:function() {
    			var params = checkObjs(items,{id:id});
    			if(!form.getForm().isValid())return;
    			if(params) {
		    		ajax({
			   			url:chg_base_url + 'setVerifyTeam',
			   			params:params,
		    			waitMsg:'提交中...',
				    	success:function(resp) {
			    			ajaxSuc(resp , INTERNAL_CHANGE_MANAGE_PANEL.refresh , null , win);
			    		}
			   		});
    			}
    		}
    	}] , '设置评审组长' , form , 100 , 600);
    };
    
    // 判定变更类别和阶段
    this.setChangeType = function(){
    	var dWidth = 340;
    	var id = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['id'];
    	var items = [
    		createProxyComm2({width:dWidth,emptyText:'请选择...',name:'changeType',fieldLabel:'变更类别',allowBlank:false} , {url:sys_basdata_url + 'getChangeTypesKV'}),
    		createNormlCommon4(dWidth , change_level_type , '验证等级' , '' , false, 'level', false)		
    	];
    	var form = getMyEmptyForm(items);
   		var win = getEmptyPanel3([{
    		text:'提交' , handler:function() {
    			var params = checkObjs(items,{id:id});
    			if(!form.getForm().isValid())return;
    			if(params) {
		    		ajax({
			   			url:chg_base_url + 'setChangeType',
			   			params:params,
		    			waitMsg:'提交中...',
				    	success:function(resp) {
			    			ajaxSuc(resp , INTERNAL_CHANGE_MANAGE_PANEL.refresh , null , win);
			    		}
			   		});
    			}
    		}
    	}] , '判定变更类别和阶段' , form , 140 , 600);
    };
    
    // 设置验证规则
    var panelObj;
    this.setVerifyRule = function(type){
    	panelObj = this;	
    	var row1 = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data;
    	var id = row1['id'];
    	var changeTypeId = row1['changeType'];
    	var arr;
    	var btn = [];
    	if(type==1){
    		// 可编辑
    		arr = converArr([
	    		{name:'changeTypeId',hidden:true},{name:'testItemsId',hidden:true},
	    		{name:'isMust',hidden:true},
	    		{name:'isEditable',hidden:true},
	    		{name:'testItemsName',width:120,header:'实验项目名称'},
	    		{name:'isMustString',width:50,header:'必须?'},
	    		{name:'changeTypeId',header:'操作',width:360, renderer:function(v,c,row) {
	    			var data = row.data;
					var isMust = data['isMust'];
					var testItemsId = data['testItemsId'];
					if(data['isEditable']==1){
						if(isMust==2)
							return '<a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.setIsMust('+id+',1,'+changeTypeId+','+testItemsId+')">必须</a> '
						else
							return '<a href="javascript:INTERNAL_CHANGE_MANAGE_PANEL.setIsMust('+id+',2,'+changeTypeId+','+testItemsId+')">可选</a> '
					}else{
						return '不可更改';
					}
				}}
	    	],true);
	    	
	    	// 提交批准按钮
	    	btn = [{
				text:'提交批准',handler:function() {
					var id = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['id'];
			    	
			    	selectTestPlanApprover('审批人' , function(testPlanApprover) {		
						ajax({
							url:chg_base_url + 'submitForTestPlanApproval',
							params:{id:id,testPlanApprover:testPlanApprover},
						    waitMsg:'提交中...',
							success:function(resp) {
								ajaxSuc(resp , INTERNAL_CHANGE_MANAGE_PANEL.refresh , null , win);
							}
						});
					});
				}
			}];
    	}else if(type==2){
    		// 只读
    		arr = converArr([
	    		{name:'changeTypeId',hidden:true},{name:'testItemsId',hidden:true},
	    		{name:'isMust',hidden:true},
	    		{name:'isEditable',hidden:true},
	    		{name:'testItemsName',width:120,header:'实验项目名称'},
	    		{name:'isMustString',width:50,header:'必须?'}
	    	],true);
	    	
	    	// 批准按钮
	    	btn = [{
				text:'批准',handler:function() {
					var id = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['id'];
			    	var evaLeader = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['evaLeader'];
			    	var mustAlertCustomer = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['mustAlertCustomer'];
			    	var mustSpplierChange = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['mustSpplierChange'];
			    	
			    	ajax({
						url:chg_base_url + 'approveTestPlan',
						params:{id:id,evaLeader:evaLeader,mustAlertCustomer:mustAlertCustomer,mustSpplierChange:mustSpplierChange},
					    waitMsg:'提交中...',
						success:function(resp) {
							ajaxSuc(resp , INTERNAL_CHANGE_MANAGE_PANEL.refresh , null , win);
						}
					});
				}
			},{
				text:'拒绝',handler:function() {
					var id = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['id'];
			    	var evaLeader = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['evaLeader'];
			    	
			    	fillRejectReason('拒绝理由' , function(rejectReason) {		
						ajax({
							url:chg_base_url + 'rejectTestPlan',
							params:{id:id,evaLeader:evaLeader,testPlanRejectedReason:rejectReason},
						    waitMsg:'提交中...',
							success:function(resp) {
								ajaxSuc(resp , INTERNAL_CHANGE_MANAGE_PANEL.refresh , null , win);
							}
						});
					});
				}
			}
			];
    	}else if(type==3){
    		// 只读
    		arr = converArr([
	    		{name:'changeTypeId',hidden:true},{name:'testItemsId',hidden:true},
	    		{name:'isMust',hidden:true},
	    		{name:'isEditable',hidden:true},
	    		{name:'testItemsName',width:120,header:'实验项目名称'},
	    		{name:'isMustString',width:50,header:'必须?'}
	    	],true);
    	}
		var grid = getGrid(null , arr , 
	    		{url:chg_base_url + "viewChangeTypeTestItems?id="+id , autoLoad:true},{region:'center'});
	    var win = getEmptyPanel3([btn] , '设置变更:[' + row1['id'] + ']实验项目' , grid , 400 , 600 , INTERNAL_CHANGE_MANAGE_PANEL);
	  
		this.refreshGrid = function(){
	    	grid.getStore().load();
	    }
    };
    
    // 修改必选可选
	this.setIsMust = function(id, isMust, changeTypeId, testItem){
	   	ajax({
    		url:chg_base_url + "updateIsMust",
    		params:{id:id,changeTypeId:changeTypeId,testItemId:testItem,isMust:isMust},
    		success:function(resp) {
    			panelObj.refreshGrid();
    		}
    	});
	}
    
    // 变更评审
   	this.fillEvaluationResult = function(){
   		var dWidth = 340;
   		var id = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['id'];
   		var evaImpactForReliabilityV = createNormlCommon(dWidth , impact_for_reliability , '风险评估-产品安全，可靠性影响' , '' , false, 'evaImpactForReliabilityValue');
   		var evaImpactForProductHandleV = createNormlCommon(dWidth , impact_for_product_handle , '风险评估-在产品，原料处理影响' , '' , false, 'evaImpactForProductHandleValue');
   		var mustVerifyV = createNormlCommon(dWidth , yes_or_no_data , '是否需要验证' , '' , false, 'mustVerifyValue');
   		var mustAlertCustomerV = createNormlCommon(dWidth , yes_or_no_data , '是否通报客户' , '' , false, 'mustAlertCustomerValue');
   		var mustSpplierChangeV = createNormlCommon(dWidth , yes_or_no_data , '是否需要供应商变更' , '' , false, 'mustSpplierChangeValue');
   		var resultV = createNormlCommon(dWidth , eva_result , '评审结论' , '' , false, 'resultValue');
   		var rejectReason = getArea({width:dWidth,height:60,name:'rejectedReason',fieldLabel:'拒绝理由'});
   		var evaComments = getArea({width:dWidth,height:60,name:'evaComments',fieldLabel:'评审备注'});
   		var items = [
    		evaImpactForReliabilityV,
    		getHidden({name:'evaImpactForReliability',allowNull:true}),
    		evaImpactForProductHandleV,
    		getHidden({name:'evaImpactForProductHandle',allowNull:true}),
    		getField({width:dWidth,name:'evaImpactForProduceEfficiency',fieldLabel:'风险评估-生产效率的影响'}),
    		mustVerifyV,
    		getHidden({name:'mustVerify',allowNull:true}),
    		mustAlertCustomerV,
    		getHidden({name:'mustAlertCustomer',allowNull:true}),
    		mustSpplierChangeV,
    		getHidden({name:'mustSpplierChange',allowNull:true}),
    		getField({width:dWidth,name:'productTreatmentAdvise',fieldLabel:'成品及原物料处理意见'}),
    		// {xtype:'textfield', fieldLabel:'验证报告', inputType:'file', name:'image', width:dWidth},
    		resultV,
    		getHidden({name:'result',allowNull:true}),
    		rejectReason,
    		evaComments
    	];
    	
    	resultV.on('select' , function() {
    		if(resultV.getValue() == '1'){
				rejectReason.hide();
				rejectReason.allowNull = true;
				evaComments.show();
				evaComments.allowNull = false;
			}else{
				rejectReason.show();
				rejectReason.allowNull = false;
				evaComments.hide();
				evaComments.allowNull = true;
			}
    	});
    	
    	var form1 = new Ext.form.FormPanel({
			bodyStyle:'padding:5px',
	    	deferredRender:false,
	    	defaultType: 'textfield',
	    	region:'center',
	    	items:items,
	    	fileUpload:true,
	    	labelWidth:85,
	    	autoScroll:true,
	    	id:'form1'
	    });
	    	
	    var win = getEmptyPanel3([{
	    	text:'提交', 
	    	name:'submit',
	    	handler:function() {
		   		var formObj = form1.getForm();
		   		if(!formObj.isValid())return;
		   		var data = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data;
		   		var id = data['id'];
		   		var params;
		   		// 设置下拉框的值
				formObj.findField("evaImpactForReliability").setValue(evaImpactForReliabilityV.getValue());
				formObj.findField("evaImpactForProductHandle").setValue(evaImpactForProductHandleV.getValue());
				formObj.findField("mustVerify").setValue(mustVerifyV.getValue());
				formObj.findField("mustAlertCustomer").setValue(mustAlertCustomerV.getValue());
				formObj.findField("mustSpplierChange").setValue(mustSpplierChangeV.getValue());
				formObj.findField("result").setValue(resultV.getValue());
				
				// 判断是否需要直接选择质量部门通报客户和供应商
				if(mustVerifyV.getValue() =='2' && resultV.getValue() == '1'){
					if(mustAlertCustomerV.getValue()=='1' || mustSpplierChangeV.getValue()=='1'){

				    	choseQualityDepartment('选择质量科人员' , function(qualityDeptUser) {
							formObj.submit({
					   			url:chg_base_url + 'saveChangeEvaluation',
					   			params:checkObjs(items,{id:id,status:8,qualityDeptUser:qualityDeptUser}),
					   			waitTitle: '请稍后',
					   			waitMsg:'提交中...',
					   			success:function(form1,resp) {
							    	uploadCallBack(resp);
							    },
							    failure:function(form1,resp){
							    	uploadCallBack(resp);
							    }
					   		});
						} , null);
					}else{
						params = checkObjs(items,{id:id,status:9});
						formObj.submit({
				   			url:chg_base_url + 'saveChangeEvaluation',
				   			params:params,
				   			waitTitle: '请稍后',
				   			waitMsg:'提交中...',
				   			success:function(form1,resp) {
						    	uploadCallBack(resp);
						    },
						    failure:function(form1,resp){
						    	uploadCallBack(resp);
						    }
				   		});
				   	}
				}else{
					params = checkObjs(items,{id:id,status:5});
					formObj.submit({
				   		url:chg_base_url + 'saveChangeEvaluation',
				   		params:params,
				   		waitTitle: '请稍后',
				   		waitMsg:'提交中...',
				   		success:function(form1,resp) {
					    	uploadCallBack(resp);
					    },
					    failure:function(form1,resp){
					    	uploadCallBack(resp);
					    }
				   	});
				}
		   		var uploadCallBack = function(resp) {
			    	var obj = resp.result;
			    	showTip2('消息' , obj.msg , 3);
			    	INTERNAL_CHANGE_MANAGE_PANEL.refresh();
			    	if(obj.status == '1') win.close();
			    };
		   	}
	    }] , '评审变更' , form1 , 460 , 600);
   	};
   	
   	// 上传测试报告
   	this.uploadResultReport = function(type){
   		var dWidth = 340;
   		var evaResult = createNormlCommon4(dWidth , yes_or_no_data , '是否同意变更' , '' , false, 'isApproveChangeSelect');
   		var rejectReason = getField({width:dWidth,name:'comments',fieldLabel:'否决原因',allowNull:true});
   		var isFinishedSecurity = createNormlCommon4(dWidth , yes_or_no_data , '安全件列名是否完成' , '' , false, 'isFinishedSecuritySelect', true);

   		var items = [
   			evaResult,
   			getHidden({name:'isApproveChange',allowNull:true}),
   			rejectReason,
    		{xtype:'textfield', fieldLabel:'验证报告', inputType:'file', name:'image', width:dWidth}
    	];
    	
    	if(type=='SAMPLE'){
	    	items = [
	   			evaResult,
	   			getHidden({name:'isApproveChange',allowNull:true}),
	   			rejectReason,
	   			getHidden({name:'isFinishedSecurity',allowNull:true}),
	   			isFinishedSecurity,
	    		{xtype:'textfield', fieldLabel:'验证报告', inputType:'file', name:'image', width:dWidth}
	    	];
	    }
    	
    	var form1 = new Ext.form.FormPanel({
			bodyStyle:'padding:5px',
	    	deferredRender:false,
	    	defaultType: 'textfield',
	    	region:'center',
	    	items:items,
	    	fileUpload:true,
	    	labelWidth:85,
	    	autoScroll:true,
	    	id:'form1'
	    });
	    
	    
	    
	    evaResult.on('select' , function() {
    		if(evaResult.getValue() == '1'){
				rejectReason.hide();
				
				rejectReason.allowNull = true;
				if(type=='SAMPLE')isFinishedSecurity.show();
			}else{
				rejectReason.show();
				if(type=='SAMPLE')isFinishedSecurity.hidden();
				rejectReason.allowNull = false;
			}
    	});
	    	
	    var win = getEmptyPanel3([{
	    	text:'提交', 
	    	name:'submit',
	    	handler:function() {
		   		var formObj = form1.getForm();
		   		if(!formObj.isValid())return;
		   		var id = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['id'];
		   		formObj.findField("isApproveChange").setValue(evaResult.getValue());
		   		if(type=='SAMPLE'){formObj.findField("isFinishedSecurity").setValue(isFinishedSecurity.getValue());}
		   		var params = checkObjs(items,{id:id,type:type});
		   		
		   		formObj.submit({
		   			url:chg_base_url + 'uploadResultReport',
		   			params:params,
		   			waitTitle: '请稍后',
		   			waitMsg:'提交中...',
		   			success:function(form1,resp) {
				    	uploadCallBack(resp);
				    },
				    failure:function(form1,resp){
				    	uploadCallBack(resp);
				    }
		   		});
		   		var uploadCallBack = function(resp) {
			    	var obj = resp.result;
			    	showTip2('消息' , obj.msg , 3);
			    	INTERNAL_CHANGE_MANAGE_PANEL.refresh();
			    	if(obj.status == '1') win.close();
			    };
		   	}
	    }] , '评审变更' , form1 , 200 , 600);
   	};
   	
   	// 结束上传报告
    this.finishUploadReport = function(){
    	var data = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data;
    	var id = data['id'];
    	
    	// 通过评审单判断是否选择质量科通报客户和供应商的人员
    	if(data['mustAlertCustomer']=='1' || data['mustSpplierChange']=='1'){
	    	choseQualityDepartment('选择质量科人员' , function(qualityDeptUser) {
				ajax({
					url:chg_base_url + 'finishUploadReport',
				   	params:{id:id,status:8,qualityDeptUser:qualityDeptUser},
				   	waitTitle: '请稍后',
				   	waitMsg:'提交中...',
				   	success:function(resp) {
				   		var respText = Ext.util.JSON.decode(resp.responseText);
		    			showTip2('提示' , respText['msg'] , 2);
		    			INTERNAL_CHANGE_MANAGE_PANEL.refresh();
					}
				});
			} , null);
		}else{
			ajax({
				url:chg_base_url + 'finishUploadReport',
			   	params:{id:id,status:9},
			   	waitTitle: '请稍后',
			   	waitMsg:'提交中...',
			   	success:function(resp) {
			   		var respText = Ext.util.JSON.decode(resp.responseText);
		    		showTip2('提示' , respText['msg'] , 2);
		    		INTERNAL_CHANGE_MANAGE_PANEL.refresh();
				}
			});
		}
    };
    
    // 查看报告
    this.viewReports = function(){
    	var data = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data;
    	
    	var htmlCode = '<div style="text-align: center;">';
    	
    	var sampleReportURL = data['sampleReportURL'];
		var smallReportURL = data['smallReportURL'];
		var middleReportURL = data['middleReportURL'];
		
		if(	sampleReportURL != ""){
			htmlCode += ' <a href='+chg_base_url+'viewDocument?docUrl='+data['sampleReportURL']+'>样本测试报告</a></br></br>'
		}
		
		if( smallReportURL != ""){
			htmlCode += ' <a href='+chg_base_url+'viewDocument?docUrl='+data['smallReportURL']+'>小批量测试报告</a></br></br>'
		}
		
		if(	middleReportURL != ""){
			htmlCode += ' <a href='+chg_base_url+'viewDocument?docUrl='+data['middleReportURL']+'>中批量测试报告</a></br></br>'
		}		
		htmlCode += '</div>';
    	
    	var btns = [{
			text:'关闭',handler:function() {
				win.close();
			}
		}];
		
    	var win = new Ext.Window({
			height:200 , width:300 , layout:'border',title:'查看测试报告',buttonAlign:'center',items:[{
				border:false,closable:true,scripts:true,autoScroll:true,region:'center',
	            discardUrl:true,nocache:true,timeout:9000,scope:this,html:htmlCode
			}],buttons:btns
		});
		win.show();
    };
    
    // 通报客户和供应商
    this.alertSupCust = function(){
    	var dWidth = 340;
    	
    	var data = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data;
    	var id = data['id'];
    	var items = [];
    	
    	var isFinishAlertCustomerV = createNormlCommon4(dWidth , yes_or_no_data , '客户报备是否完成' , '' , false, 'isFinishedAlertCustomerV', true);
    	var isFinishAlertSuppV = createNormlCommon4(dWidth , yes_or_no_data , '供应商变更是否完成' , '' , false, 'isFinishedSupChangeV', true);
    	
    	// 通过评审单判断是否选择质量科通报客户和供应商的人员
    	if(data['mustAlertCustomer']=='1'&&data['mustSpplierChange']!='1'){
    		items = [
    			isFinishAlertCustomerV,
    			getHidden({name:'isFinishedAlertCustomer',allowNull:true}),
    			getField({width:dWidth,name:'alertCustomerNumber',fieldLabel:'依据（编号）',allowNull:true}),
    			{xtype:'textfield', fieldLabel:'依据附件', inputType:'file', name:'image', width:dWidth},
    		];
    	}else if(data['mustSpplierChange']=='1'&&data['mustAlertCustomer']!='1'){
    		items = [
    			isFinishAlertSuppV,
    			getHidden({name:'isFinishedSupChange',allowNull:true}),
    			getField({width:dWidth,name:'finishedSupChangeNumber',fieldLabel:'依据（编号）',allowNull:true}),
    			{xtype:'textfield', fieldLabel:'依据附件', inputType:'file', name:'image', width:dWidth},
    		];
    	}else{
    		items = [
    			isFinishAlertCustomerV,
    			getHidden({name:'isFinishedAlertCustomer',allowNull:true}),
    			getField({width:dWidth,name:'alertCustomerNumber',fieldLabel:'依据（编号）',allowNull:true}),
    			isFinishAlertSuppV,
    			getHidden({name:'isFinishedSupChange',allowNull:true}),
    			getField({width:dWidth,name:'finishedSupChangeNumber',fieldLabel:'依据（编号）',allowNull:true}),
    			{xtype:'textfield', fieldLabel:'依据附件', inputType:'file', name:'image', width:dWidth}
    		];
    	}
    	
    	var form1 = new Ext.form.FormPanel({
			bodyStyle:'padding:5px',
	    	deferredRender:false,
	    	defaultType: 'textfield',
	    	region:'center',
	    	items:items,
	    	fileUpload:true,
	    	labelWidth:85,
	    	autoScroll:true,
	    	id:'form1'
	    });
	    
   		var win = getEmptyPanel3([{
    		text:'提交' , handler:function() {
    			var formObj = form1.getForm();
    			if(!formObj.isValid())return;
    			
    			if(data['mustAlertCustomer']=='1'&&data['mustSpplierChange']!='1'){
		    		formObj.findField("isFinishedAlertCustomer").setValue(isFinishAlertCustomerV.getValue());
		    	}else if(data['mustSpplierChange']=='1'&&data['mustAlertCustomer']!='1'){
		    		formObj.findField("isFinishedSupChange").setValue(isFinishAlertSuppV.getValue());
		    	}else{
		    		formObj.findField("isFinishedAlertCustomer").setValue(isFinishAlertCustomerV.getValue());
		    		formObj.findField("isFinishedSupChange").setValue(isFinishAlertSuppV.getValue());
		    	}
    			var params = checkObjs(items,{id:id,evaLeader:data['evaLeader']});
    			
    			formObj.submit({
		   			url:chg_base_url + 'alertCustSup',
		   			params:params,
		   			waitTitle: '请稍后',
		   			waitMsg:'提交中...',
		   			success:function(form1,resp) {
				    	uploadCallBack(resp);
				    },
				    failure:function(form1,resp){
				    	uploadCallBack(resp);
				    }
		   		});
		   		var uploadCallBack = function(resp) {
			    	var obj = resp.result;
			    	showTip2('消息' , obj.msg , 3);
			    	INTERNAL_CHANGE_MANAGE_PANEL.refresh();
			    	if(obj.status == '1') win.close();
			    };
    		}
    	}] , '通报客户和供应商' , form1 , 240 , 600);
    };
   	
   	// 确认变更评审
   	this.confirmEvaluation = function(){
   		var dWidth = 340;
   		var lbWidth = 150;
   		var data = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data;
   		
   		var id = data['id'];
   		
   		var evaResult = createNormlCommon4(dWidth , yes_or_no_data , '是否同意变更' , '' , false, 'isApproveChange');
   		var rejectReason = getField({width:dWidth,name:'rejectReason',fieldLabel:'否决原因',allowNull:true});
   		var deployDate = creDate({fieldLabel:'变更实施时间',name:'deployChangeDate',width:dWidth});
   		var sampleReportURL = data['sampleReportURL'];
		var smallReportURL = data['smallReportURL'];
		var middleReportURL = data['middleReportURL'];
		var sampleReport, smallReport, middleReport;
		
		if(	sampleReportURL != ""){
			sampleReport = getLablel3(chg_base_url+'viewDocument?docUrl='+sampleReportURL,'样本测试报告','查看报告');
		}else{
			sampleReport = getLablel3('javascript:#','样本测试报告','未验证');
		}
		
		if( smallReportURL != ""){
			smallReport = getLablel3(chg_base_url+'viewDocument?docUrl='+smallReportURL,'小批量测试报告','查看报告');
		}else{
			smallReport = getLablel3('javascript:#','小批量测试报告','未验证');
		}
		
		if(	middleReportURL != ""){
			middleReport = getLablel3(chg_base_url+'viewDocument?docUrl='+middleReportURL,'中批量测试报告','查看报告');
		}else{
			middleReport = getLablel3('javascript:#','中批量测试报告','未验证');
		}
   		
   		var items = [
   			sampleReport,
    		getLablel3('javascript:#','样本是否合格',data['sampleIsQualifiedString']),
    		smallReport,
    		getLablel3('javascript:#','小批量是否合格',data['smallIsQualifiedString']),
    		middleReport,
    		getLablel3('javascript:#','中批量是否合格',data['middleIsQualifiedString']),
    		getLablel3('javascript:#','客户报备是否完成',data['isFinishedAlertCustomerString']),
    		getLablel3('javascript:#','依据',data['alertCustomerNumber']),
    		getLablel3('javascript:#','供应商变更是否完成',data['isFinishedSupChangeString']),
    		getLablel3('javascript:#','依据',data['finishedSupChangeNumber']),
    		getLablel3('javascript:#','安全件列名是否完成',data['isFinishedSecurityString']),
    		getField({width:dWidth,name:'other',fieldLabel:'其他',allowNull:true}),
    		createNormlCommon4(dWidth , yes_or_no_data , '变更是否合格' , '' , false, 'changeResultIsQualify', true),
    		evaResult,
    		rejectReason,
    		getField({width:dWidth,name:'verifyMembers',fieldLabel:'参评人员',allowNull:true}),
    		deployDate
    	];
    	
    	evaResult.on('select' , function() {
    		if(evaResult.getValue() == '1'){
				rejectReason.hide();
				deployDate.show();
				rejectReason.allowNull = true;
				deployDate.allowNull = false;
			}else{
				rejectReason.show();
				deployDate.hide();
				rejectReason.allowNull = false;
				deployDate.allowNull = true;
			}
    	});
    	
    	var verifyConfirmItems = {
			xtype : 'fieldset',
			title : '验证确认',
			collapsible : false, //可折叠
			height : 400,
			labelWidth : lbWidth,
			labelSeparator : ':',
			autoWidth : true,
			defaults : {width : dWidth, allowBlank : true,xtype : 'textfield', msgTarget : 'side'},
			labelAlign : 'left',
			items : [
				items[0],items[1],items[2],items[3],items[4],items[5],items[6],
    			items[7],items[8],items[9],items[10],items[11],items[12]
			]
		};
		
		var changeConfirmItems = {
			xtype : 'fieldset',
			title : '变更确认评审',
			collapsible : false, //可折叠
			height : 140,
			labelWidth : lbWidth,
			labelSeparator : ':',
			autoWidth : true,
			defaults : {width : dWidth, allowBlank : false,xtype : 'textfield', msgTarget : 'side'},
			labelAlign : 'left',
			items : [
    			items[13],items[14],items[15],items[16]
			]
		};
		
		var form = getMyEmptyForm([verifyConfirmItems,changeConfirmItems]);
   		var win = getEmptyPanel3([{
    		text:'提交' , handler:function() {
    			var params = checkObjs(items,{changeId:id});
    			if(!params)return;
		    	ajax({
			   		url:chg_base_url + 'saveDeployChange',
			   		params:params,
		    		waitMsg:'提交中...',
				   		success:function(resp) {
			    		ajaxSuc(resp , INTERNAL_CHANGE_MANAGE_PANEL.refresh , null , win);
			    	}
			   	});
    		}
    	}] , '确认评审' , form , 500 , 600);
   	}
   	
   	// 部门领导是否同意下发
   	this.approveDeploy = function(status){
   		var data = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data;
   		var id = data['id'];
   		var evaLeader = data['evaLeader'];
   		var appliedUserId = data['appliedUserId'];
   		
   		if(status=="23"){
   			fillRejectReason('拒绝理由' , function(rejectReason) {		
				ajax({
					url:chg_base_url + 'approveDeploy',
					params:{id:id,status:status,evaLeader:evaLeader,appliedUserId:appliedUserId,rejectedReason:rejectReason},
					waitMsg:'提交中...',
					success:function(resp) {
						var respText = Ext.util.JSON.decode(resp.responseText);
		    			showTip2('提示' , respText['msg'] , 2);
		    			INTERNAL_CHANGE_MANAGE_PANEL.refresh();
				   	}
			   	});
			});
   		}else{
	   		ajax({
				url:chg_base_url + 'approveDeploy',
				params:{id:id,status:status,evaLeader:evaLeader,appliedUserId:appliedUserId},
				waitMsg:'提交中...',
				success:function(resp) {
					var respText = Ext.util.JSON.decode(resp.responseText);
			    	showTip2('提示' , respText['msg'] , 2);
			    	INTERNAL_CHANGE_MANAGE_PANEL.refresh();
			   	}
		   	});
		}
   		
   	};
   	
   	// 下发变更通知单，选择各环节的人员
   	this.selectDeployDeptUsers = function(){
   		var dWidth = 340;
   		var lbWidth = 150;
   		var data = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data;
   		var id = data['id'];
   		
   		var appliedUserId = data['appliedUserId'];
		
		var researchDept = createProxyComm2({width:dWidth,emptyText:'请选择...',name:'researchDeptId',fieldLabel:'应研所'},{url:sys_base_url + 'getDepartmentKV'});
		var researchDeptUser = createProxyComm2({width:dWidth,emptyText:'请选择...',name:'researchDeptUserId',fieldLabel:'应研所-负责人员'},{url:sys_base_url + 'getUsersByDept'});
		var engineeringDept = createProxyComm2({width:dWidth,emptyText:'请选择...',name:'engineeringDeptId',fieldLabel:'工程部'},{url:sys_base_url + 'getDepartmentKV'});
		var engineeringDeptUser = createProxyComm2({width:dWidth,emptyText:'请选择...',name:'engineeringDeptUserId',fieldLabel:'工程部-负责人员'},{url:sys_base_url + 'getUsersByDept'});
		var qualityDept = createProxyComm2({width:dWidth,emptyText:'请选择...',name:'qualityDeptId',fieldLabel:'质量部门'},{url:sys_base_url + 'getDepartmentKV'});
    	var qualityDeptUser = createProxyComm2({width:dWidth,emptyText:'请选择...',name:'qualityDeptUserId',fieldLabel:'质量部门-负责人员'},{url:sys_base_url + 'getUsersByDept'});
    	var productDept = createProxyComm2({width:dWidth,emptyText:'请选择...',name:'productDeptId',fieldLabel:'生产班组'},{url:sys_base_url + 'getDepartmentKV'});
    	var productDeptUser = createProxyComm2({width:dWidth,emptyText:'请选择...',name:'productDeptUserId',fieldLabel:'生产班组-负责人员'},{url:sys_base_url + 'getUsersByDept'});
    	var summaryDept = createProxyComm2({width:dWidth,emptyText:'请选择...',name:'summaryDeptId',fieldLabel:'综合管理部门'},{url:sys_base_url + 'getDepartmentKV'});
    	var summaryDeptUser = createProxyComm2({width:dWidth,emptyText:'请选择...',name:'summaryDeptUserId',fieldLabel:'综合管理部门-负责人员'},{url:sys_base_url + 'getUsersByDept'});
		
		var items = [
			researchDept,
    		researchDeptUser,
    		engineeringDept,
    		engineeringDeptUser,
    		qualityDept,
    		qualityDeptUser,
    		productDept,
    		productDeptUser,
    		summaryDept,
    		summaryDeptUser
    	];
    	
    	// 级联
    	researchDept.on('select', function(){
			researchDeptUser.store.load({
				params:{deptId:researchDept.getValue()}
			});
    	});
    	engineeringDept.on('select', function(){
			engineeringDeptUser.store.load({
				params:{deptId:engineeringDept.getValue()}
			});
    	});
    	qualityDept.on('select', function(){
			qualityDeptUser.store.load({
				params:{deptId:qualityDept.getValue()}
			});
    	});
    	productDept.on('select', function(){
			productDeptUser.store.load({
				params:{deptId:productDept.getValue()}
			});
    	});
    	summaryDept.on('select', function(){
			summaryDeptUser.store.load({
				params:{deptId:summaryDept.getValue()}
			});
    	});
		
		var form = getMyEmptyForm(items);
   		var win = getEmptyPanel3([{
    		text:'提交' , handler:function() {
    			var params = checkObjs(items,{changeId:id,appliedUserId:appliedUserId});
    			if(params) {
		    		ajax({
			   			url:chg_base_url + 'selectDeployDeptUsers',
			   			params:params,
		    			waitMsg:'提交中...',
				    		success:function(resp) {
			    			ajaxSuc(resp , INTERNAL_CHANGE_MANAGE_PANEL.refresh , null , win);
			    		}
			   		});
    			}
    		}
    	}] , '设置执行部门' , form , 400 , 600);
   	};
   	
   	// 执行变更
   	this.deployChange = function(status){
   		var dWidth = 340;
   		var data = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data;
   		var id = data['id'];
   		var items;
   		
   		// 判断下一个状态
   		var researchDeptUserId = data['researchDeptUserId'];
   		var engineeringDeptUserId = data['engineeringDeptUserId'];
   		var qualityDeptUserId = data['qualityDeptUserId'];
   		var productDeptUserId = data['productDeptUserId'];
   		var summaryDeptUserId = data['summaryDeptUserId'];
   		var appliedUserId = data['appliedUserId'];
   		var type;
   		
   		var researchDeptIsBomChangedV = createNormlCommon(dWidth , yes_or_no_data , '修改设计BOM并存档' , '' , false, 'researchDeptIsBomChangedV');
   		var researchDeptIsDrawingChnagedV = createNormlCommon(dWidth , yes_or_no_data , '修改设计图纸并存档' , '' , false, 'researchDeptIsDrawingChnagedV');
   		var researchDeptIsDesignDocChangedV = createNormlCommon(dWidth , yes_or_no_data , '修改设计规格书并存档' , '' , false, 'researchDeptIsDesignDocChangedV');
   		
   		var engineeringDeptIsBomChangedV = createNormlCommon(dWidth , yes_or_no_data , '修改设计BOM并存档' , '' , false, 'engineeringDeptIsBomChangedV');
		var engineeringDeptIsSopChangedV = createNormlCommon(dWidth , yes_or_no_data , '修改设SOP文档并存档' , '' , false, 'engineeringDeptIsSopChangedV');
		var engineeringDeptIsMoldChangedV = createNormlCommon(dWidth , yes_or_no_data , '工模具准备或修改' , '' , false, 'engineeringDeptIsMoldChangedV');
		var engineeringDeptIsProcChangedV = createNormlCommon(dWidth , yes_or_no_data , '程序准备' , '' , false, 'engineeringDeptIsProcChangedV');
		var engineeringDeptIsQcChangedV = createNormlCommon(dWidth , yes_or_no_data , '修改QC工程图' , '' , false, 'engineeringDeptIsQcChangedV');
   		
   		var qualityDeptIsInspectDocChangedV = createNormlCommon(dWidth , yes_or_no_data , '完成对应检验文档修改' , '' , false, 'qualityDeptIsInspectDocChangedV');
		var qualityDpetIsTrainedV = createNormlCommon(dWidth , yes_or_no_data , '完成变更培训' , '' , false, 'qualityDpetIsTrainedV');
		var qualityDpetIsUpgradeInspectionV = createNormlCommon(dWidth , yes_or_no_data , '实施变更品加严检验' , '' , false, 'qualityDpetIsUpgradeInspectionV');
		var qualityDeptIsMarkInFirst3V = createNormlCommon(dWidth , yes_or_no_data , '进行前3批变更品标识' , '' , false, 'qualityDeptIsMarkInFirst3V');
   		
   		var productDeptIsMaterialCheckedV = createNormlCommon(dWidth , yes_or_no_data , '生产资料齐套检查' , '' , false, 'productDeptIsMaterialCheckedV');
		var productDeptIsTrainedV = createNormlCommon(dWidth , yes_or_no_data , '完成变更培训' , '' , false, 'productDeptIsTrainedV');
		var productDeptIsRegistedV = createNormlCommon(dWidth , yes_or_no_data , '变更执行登记' , '' , false, 'productDeptIsRegistedV');
   		
   		var summaryIsNumberBeforeChangeSupV = createNormlCommon(dWidth , yes_or_no_data , '变更前供应商物料数量' , '' , false, 'summaryIsNumberBeforeChangeSupV');
   		var summaryIsNumberBeforeChangeProdV = createNormlCommon(dWidth , yes_or_no_data , '变更前产品、在制品数量' , '' , false, 'summaryIsNumberBeforeChangeProdV');
   		var summaryIsImpactShipMentV = createNormlCommon(dWidth , yes_or_no_data , '变更是否影响产品出货' , '' , false, 'summaryIsImpactShipMentV');
   		
   		if(researchDeptUserId==login_user_id){
   			// 应研所
   			items = [
	    		researchDeptIsBomChangedV,
	    		getHidden({name:'researchDeptIsBomChanged',allowNull:true}),
				researchDeptIsDrawingChnagedV,
				getHidden({name:'researchDeptIsDrawingChnaged',allowNull:true}),
				researchDeptIsDesignDocChangedV,
				getHidden({name:'researchDeptIsDesignDocChanged',allowNull:true}),
				{xtype:'textfield', fieldLabel:'附件', inputType:'file', name:'image', width:dWidth}
			];
			
			type=17;
			
   		}else if(engineeringDeptUserId==login_user_id){
   			// 工程部
   			items = [
	    		engineeringDeptIsBomChangedV,
	    		getHidden({name:'engineeringDeptIsBomChanged',allowNull:true}),
	    		engineeringDeptIsSopChangedV,
	    		getHidden({name:'engineeringDeptIsSopChanged',allowNull:true}),
	    		engineeringDeptIsMoldChangedV,
	    		getHidden({name:'engineeringDeptIsMoldChanged',allowNull:true}),
	    		engineeringDeptIsProcChangedV,
	    		getHidden({name:'engineeringDeptIsProcChanged',allowNull:true}),
	    		engineeringDeptIsQcChangedV,
	    		getHidden({name:'engineeringDeptIsQcChanged',allowNull:true}),
				{xtype:'textfield', fieldLabel:'附件', inputType:'file', name:'image', width:dWidth}
			];
			type=18;
   		}else if(qualityDeptUserId==login_user_id){
   			// 质量部门
   			items=[
	    		qualityDeptIsInspectDocChangedV,
	    		getHidden({name:'qualityDeptIsInspectDocChanged',allowNull:true}),
	    		qualityDpetIsTrainedV,
	    		getHidden({name:'qualityDpetIsTrained',allowNull:true}),
	    		qualityDpetIsUpgradeInspectionV,
	    		getHidden({name:'qualityDpetIsUpgradeInspection',allowNull:true}),
	    		qualityDeptIsMarkInFirst3V,
	    		getHidden({name:'qualityDeptIsMarkInFirst3',allowNull:true}),
				{xtype:'textfield', fieldLabel:'附件', inputType:'file', name:'image', width:dWidth}
			];
			type=19;
   		}else if(productDeptUserId==login_user_id){
   			// 生产班组
   			items=[
	    		productDeptIsMaterialCheckedV,
	    		getHidden({name:'productDeptIsMaterialChecked',allowNull:true}),
	    		productDeptIsTrainedV,
	    		getHidden({name:'productDeptIsTrained',allowNull:true}),
	    		productDeptIsRegistedV,
	    		getHidden({name:'productDeptIsRegisted',allowNull:true}),
				{xtype:'textfield', fieldLabel:'附件', inputType:'file', name:'image', width:dWidth}
			];
			type=20;
   		}else if(summaryDeptUserId==login_user_id){
   			// 综合
   			items=[
	    		summaryIsNumberBeforeChangeSupV,
	    		getHidden({name:'summaryIsNumberBeforeChangeSup',allowNull:true}),
    			getField({width:dWidth,name:'summaryNumberBeforeChangeSup',fieldLabel:'变更前供应商物料数量',regex:/^\d{0,}$/, regexText: "只能输入数字"}),
				creDate({fieldLabel:'变更后交付时间',name:'summaryDeliverDateAfterChange',width:dWidth}),
				summaryIsNumberBeforeChangeProdV,
				getHidden({name:'summaryIsNumberBeforeChangeProd',allowNull:true}),
				getField({width:dWidth,name:'summaryNumberBeforeChangeProd',fieldLabel:'变更前产品、在制品数量',regex:/^\d{0,}$/, regexText: "只能输入数字"}),
				summaryIsImpactShipMentV,
				getHidden({name:'summaryIsImpactShipMent',allowNull:true}),
				getField({width:dWidth,name:'summaryNewProdBatchNumber',fieldLabel:'新产品首批号'}),
				{xtype:'textfield', fieldLabel:'附件', inputType:'file', name:'image', width:dWidth}
			];
			type=21;
   		}
   		var form1 = new Ext.form.FormPanel({
			bodyStyle:'padding:5px',
	    	deferredRender:false,
	    	defaultType: 'textfield',
	    	region:'center',
	    	items:items,
	    	fileUpload:true,
	    	labelWidth:85,
	    	autoScroll:true,
	    	id:'form1'
	    });
   		var win = getEmptyPanel3([{
    		text:'提交' , handler:function() {
    			var params = checkObjs(items,{changeId:id, type:type});
    			var formObj = form1.getForm();
    			if(!formObj.isValid())return;
    			if(researchDeptUserId==login_user_id){
    				formObj.findField("researchDeptIsBomChanged").setValue(researchDeptIsBomChangedV.getValue());
    				formObj.findField("researchDeptIsDrawingChnaged").setValue(researchDeptIsDrawingChnagedV.getValue());
    				formObj.findField("researchDeptIsDesignDocChanged").setValue(researchDeptIsDesignDocChangedV.getValue());
		   		}else if(engineeringDeptUserId==login_user_id){
		   			formObj.findField("engineeringDeptIsBomChanged").setValue(engineeringDeptIsBomChangedV.getValue());
    				formObj.findField("engineeringDeptIsSopChanged").setValue(engineeringDeptIsSopChangedV.getValue());
    				formObj.findField("engineeringDeptIsMoldChanged").setValue(engineeringDeptIsMoldChangedV.getValue());
    				formObj.findField("engineeringDeptIsProcChanged").setValue(engineeringDeptIsProcChangedV.getValue());
    				formObj.findField("engineeringDeptIsQcChanged").setValue(engineeringDeptIsQcChangedV.getValue());
		   		}else if(qualityDeptUserId==login_user_id){
		   			formObj.findField("qualityDeptIsInspectDocChanged").setValue(qualityDeptIsInspectDocChangedV.getValue());
    				formObj.findField("qualityDpetIsTrained").setValue(qualityDpetIsTrainedV.getValue());
    				formObj.findField("qualityDpetIsUpgradeInspection").setValue(qualityDpetIsUpgradeInspectionV.getValue());
    				formObj.findField("qualityDeptIsMarkInFirst3").setValue(qualityDeptIsMarkInFirst3V.getValue());
		   		}else if(productDeptUserId==login_user_id){
		   			formObj.findField("productDeptIsMaterialChecked").setValue(productDeptIsMaterialCheckedV.getValue());
    				formObj.findField("productDeptIsTrained").setValue(productDeptIsTrainedV.getValue());
    				formObj.findField("productDeptIsRegisted").setValue(productDeptIsRegistedV.getValue());
		   		}else if(summaryDeptUserId==login_user_id){
		   			formObj.findField("summaryIsNumberBeforeChangeSup").setValue(summaryIsNumberBeforeChangeSupV.getValue());
    				formObj.findField("summaryIsNumberBeforeChangeProd").setValue(summaryIsNumberBeforeChangeProdV.getValue());
    				formObj.findField("summaryIsImpactShipMent").setValue(summaryIsImpactShipMentV.getValue());
		   		}
    			if(!formObj.isValid())return;
    			if(params) {
    				formObj.submit({
				   		url:chg_base_url + 'deployChange',
				   		params:params,
				   		waitTitle: '请稍后',
				   		waitMsg:'提交中...',
				   		success:function(form1,resp) {
					    	uploadCallBack(resp);
					    },
					    failure:function(form1,resp){
					    	uploadCallBack(resp);
					    }
				   	});
				   	var uploadCallBack = function(resp) {
				    	var obj = resp.result;
				    	showTip2('消息' , obj.msg , 3);
				    	INTERNAL_CHANGE_MANAGE_PANEL.refresh();
				    	win.close();
				    	view_notification_win.closeParentWin();
				    };
		    		
    			}
    		}
    	}] , '执行变更' , form1 , 300 , 600);
   	};
   	
   	//结束流程
   	this.finished = function(){
   		var data = INTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data;
   		var id = data['id'];
   		var appliedUserId = data['appliedUserId'];
   		ajax({
			url:chg_base_url + 'finished',
			params:{id:id,appliedUserId:appliedUserId},
			waitMsg:'提交中...',
			success:function(resp) {
				var respText = Ext.util.JSON.decode(resp.responseText);
		    	showTip2('提示' , respText['msg'] , 2);
		    	INTERNAL_CHANGE_MANAGE_PANEL.refresh();
		   	}
		});
   	}
};
Ext.extend(CMS.InternalChangeManagePanel, Ext.grid.GridPanel);